﻿using Abp.Runtime.Validation;
using Microsoft.EntityFrameworkCore.Internal;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace NetCore.Dtos
{
    /// <summary>
    /// 基础输入类
    /// </summary>
    [Description("基础输入类")]
    public class InputIdsDto<TPrimaryKey> : ICustomValidate
    {
        public InputIdsDto()
        {
            Ids = new List<TPrimaryKey>();
        }

        /// <summary>
        /// 主键Id必填
        /// </summary>
        [Required, Description("唯一标识")]
        public List<TPrimaryKey> Ids { get; set; }

        public void AddValidationErrors(CustomValidationContext context)
        {
            if (!Ids.Any())
            {
                context.Results.Add(new ValidationResult("至少选中一条数据!"));
            }
        }
    }
    /// <summary>
    /// long类型的输入基类
    /// </summary>
    public class InputIdsDto : InputIdsDto<int>
    {

    }
}
